package com.wanlian.socketserver.Device;

import com.wanlian.socketserver.Device.worker.DeviceServerWorker;
import com.wanlian.util.HttpUtils;

public class DeviceApplication {

    public void runServer() throws Exception {
        initDevices();
        DeviceServer deviceServer = new DeviceServer(Constants.BIND_PORT);
        deviceServer.setPublicKey("d5c0bfaca2934f22bc3f8ff4b7b0dc97");
        deviceServer.run();
        DeviceServerWorker.setServer(deviceServer);
        DeviceServerWorker.work();
    }

    private void initDevices() {
        try {
            HttpUtils.sendGetNoParam(ServerConfig.deviceOffLineAllUrl);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public void runFileServer() throws Exception {
        DeviceServer deviceServer = new DeviceServer(Constants.BIND_FILE_PORT);
        deviceServer.setPublicKey("d5c0bfaca2934f22bc3f8ff4b7b0dc97");
//        deviceServer.runFileServer();
//        DeviceServerFileWorker.setServer(deviceServer);
//        DeviceServerFileWorker.work();
    }
}
